require 'watir'

class Application
  
  @@application_url = 'http://localhost:9080/inTouch/'
  @@new_browser_html_path =
  File.join(File.expand_path(File.dirname(__FILE__)), 'new_browser.html').gsub("/" , "\\" )
  
  attr_reader :browser
  
  def initialize(force_new_session = false)
    @src_dir = File.expand_path(File.dirname("../../../")).tr('/','\\')
    if force_new_session
      @browser = create_browser_with_new_session
    else
      @browser = Watir::IE.new
    end
    @browser.set_fast_speed
  end
  
  def goLogin
    @browser.goto @@application_url
  end
  
  def doLogin(userName, password)
    @browser.text_field(:name, "userName").set(userName)
    @browser.text_field(:name, "password").set(password)
    @browser.button(:name, "login").click
  end
  
  def doLogoffAndCloseBrowser
    @browser.link(:text, "Logout").click
    @browser.close
  end
  
end
